#!/bin/bash

# Check if user is root
if [ $(id -u) != "0" ]; then
    printf "Error: You must be root to run this script!\n"
    exit 1
fi

printf "\n"
printf "==========================\n"
printf " RZ SZ Install		  \n"
printf "==========================\n"
printf "\n\n"

if [ ! -s websrc ]; then    
    printf "Error: directory websrc not found.\n"
    exit 1
fi

cd websrc

#compile install RZ SZ
printf "\n========= RZSZ install start... =========\n\n"

wget http://freeware.sgi.com/source/rzsz/rzsz-3.48.tar.gz
tar zxf  rzsz-3.48.tar.gz
cd src

sed -i 's/^OFLAG= -O/OFLAG= -O -DREGISTERED/g' Makefile
make posix
cp rz sz /usr/bin/

cd -

printf "\n========== RZSZ install Completed! ========\n\n"
printf "============== The End. ==============\n"